/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-03-17
 * Time: 10:12
 */
public class Main {
    public static void main(String[] args) {
        int n = 7;
        int x = 3;

        //1.给一个数n确定它的二进制表示的第x位是0还是1
        int result_1 = (n >> x) & 1;
        System.out.println(result_1);
        //2.将一个数n的二进制表示第x位修改成1
        int result_2 = n | (1<<x);
        System.out.println(result_2);
        //3.将一个数n的二进制表示第x位修改成1
        int result_3 = n & (~(1 << x));
        System.out.println(result_3);
        //4.提取一个数n二进制中最右侧的1
        int result_4 = n & (-n);
        System.out.println(result_4);
        //5.干掉一个数n二进制中最右侧的1
        int result_5 = n & (n-1);
        System.out.println(result_5);
    }
}
